home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr49 / strpp300.zip / FILESTR.CPP < prev    next >
C/C++ Source or Header  |  1993-04-11  |  1KB  |  59 lines

  1. /* -------------------------------------------------------------------- */
  2. /* String++ Version 3.00                                       04/10/93 */
  3. /*                                                                      */
  4. /* Enhanced string class for Turbo C++/Borland C++.                     */
  5. /* Copyright 1991-1993 by Carl W. Moreland                              */
  6. /*                                                                      */
  7. /* filestr.cpp                                                          */
  8. /* -------------------------------------------------------------------- */
  9.  
  10. #include "filestr.h"
  11.  
  12. FileString::FileString(const char* PathName)
  13. {
  14.   String tmp = PathName;
  15.   Process(tmp);
  16. }
  17.  
  18. FileString::FileString(const String& PathName)
  19. {
  20.   Process(PathName);
  21. }
  22.  
  23. void FileString::Process(const String& PathName)
  24. {
  25.   int n;
  26.  
  27.   n = PathName.FindLast("\\");
  28.  
  29.   Path     = PathName.SubStr(0, n+1);
  30.   FileName = PathName.SubStr(n+1, PathName.Len()-n-1);
  31.  
  32.   n = FileName.FindLast(".");
  33.  
  34.   if(n != -1)
  35.   {
  36.     Name = FileName.SubStr(0, n);
  37.     Ext  = FileName.SubStr(n+1, FileName.Len()-n-1);
  38.   }
  39.   else
  40.     Name = FileName;
  41.  
  42.   if(Path[1] == ':')
  43.   {
  44.     Drive = Path.SubStr(0,2);
  45.     Path.Delete(0,2);
  46.   }
  47. }
  48.  
  49. void FileString::operator=(const char* PathName)
  50. {
  51.   String tmp = PathName;
  52.   Process(tmp);
  53. }
  54.  
  55. void FileString::operator=(const string& PathName)
  56. {
  57.   Process(PathName);
  58. }
  59.